/**
 * 添加或者修改页面
 */
var BtyExpendInfoDlg = {
    data: {
        shopCode: "",
        shopName: "",
        money: "",
        remark: "",
        time: "",
        createUser: "",
        createTime: "",
        modifyUser: "",
        modifyTime: ""
    }
};

layui.use(['form', 'admin', 'ax','laydate'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var laydate = layui.laydate;
    //让当前iframe弹层高度适应
    admin.iframeAuto();

    var qyAjax = new $ax("/dbiShop/shopList");
    qyAjax.set("type", 2);
    var qyResult = qyAjax.start();
    $.each(qyResult.data, function (index, data) {
        $("#shopCode").append("<option value='" + data.code + "'>" + data.name + "</option>");
    });
    form.render('select');

    laydate.render({
       elem:'#time',
       max:Feng.currentDate()
    });


    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {

        var ajax = new $ax(Feng.ctxPath + "/btyExpend/addItem", function (data) {
            Feng.success("添加成功！");
            // window.location.href = Feng.ctxPath + '/btyExpend'
        }, function (data) {
            Feng.error("添加失败！" + data.responseJSON.message)
        });
        //门店名
        ajax.set("shopName", $("#shopCode").find("option:selected").text());
        ajax.set(data.field);
        ajax.start();

        return false;
    });

    //返回按钮
    $("#backupPage").click(function () {
        window.location.href = Feng.ctxPath + '/btyExpend'
    });

});